{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/header.html"}

{literal}
<script type="text/javascript">
    $(function(){
        $('.assortment').hover(function(){
            $('.assort_list').stop().fadeIn();
        },function(){
            $('.assort_list').stop().fadeOut();
        });
    });
</script>
<!--<script type="text/javascript" src="/js/jqPaginator.js"></script>-->
<script type="text/javascript">
    var page_cur = 1; //当前页
    var total_num, page_size, page_total_num;//总记录数,每页条数,总页数

    function getData(page) { //获取当前页数据
        $.ajax({
            type: 'GET',
            url: '/test/pagejson',
            data: {'page': page},
            dataType: 'text',
            success: function(json) {
                $(".product_iwrap").empty();
               var json = $.parseJSON(json);
                total_num = json.total_num;//总记录数
                page_size = json.page_size;//每页数量
                page_cur = page;//当前页
                page_total_num = json.page_total_num;//总页数
                $("#currPageNum").val(page_cur);
                $("#totalPages").val(page_total_num);
                $("#currPage").text(page_cur);
                $("#totalPage").text(page_total_num);
                var li = "";
                var list = json.list;

                for(index in list) { //遍历返回json
                    li += "<li class=\"product_item\">";
                        li+="<div class=\"product_list_title\">";
                            li+="<span class=\"items icons\">+</span>";
                            li+="<span class=\"items breed\">"+list[index]['cate_name']+"</span>";
                            li+="<span class=\"items grade\">"+list[index]['product_name']+"</span>";
                            li+=" <span class=\"items firm\">"+list[index]['brand_name']+"</span>";
                            li+="<span class=\"items price orange fwb\">"+list[index]['price']+"</span>";
                            li+="<span class=\"items number\">"+list[index]['num']+"</span>";
                            li+="<span class=\"items supplier blue\">4家报价</span>";
                            li+="<span class=\"items operate\"><a href=\"#\">查看</a></span>";
                        li+="</div>";

                        li+="<ul class=\"product_list_content\">";
                                for(list_index in list[index]['index_list']) {
                                li+="<li>";
                                    li+="<div class=\"plc_items\">";
                                        li+="<div class=\"items plc_items_text\"><i class=\"plc_icon\">自营现货</i>";
                                            li+="<p class=\"plc_text\">"+list[index]['index_list'][list_index]['cate_name']+list[index]['index_list'][list_index]['product_name']+list[index]['index_list'][list_index]['brand_name']+"<span class=\"green\">现货</span></p>";
                                        li+="</div>";
                                        li+="<span class=\"items firm\">交货地：上海宝山</span>";
                                        li+="<span class=\"items price blue fwb\">"+list[index]['index_list'][list_index]['price']+"</span>";
                                        li+="<span class=\"items number\">"+list[index]['index_list'][list_index]['num']+"</span>";
                                        li+="<span class=\"items time\">4分钟前</span>";
                                        li+="<span class=\"items operate\">";
                                        li+="<a href=\"#\" class=\"buy\">立即认购</a><a href=\"#\" class=\"negotiate\">委托洽谈</a>";
                                        li+="</span>";
                                    li+="</div>";
                                li+="</li>";
                                };
                        li+="</ul>";
                    li +="<li>";
                };
                $(".product_iwrap").html(li);
            },
            complete: function() {
                getPageBar();//js生成分页，可用程序代替
            },
            error: function() {
                alert("数据异常,请检查是否json格式");
            }
        });
    }

    function getPageBar() { //js生成分页
        if (page_cur > page_total_num)
            page_cur = page_total_num;//当前页大于最大页数
        if (page_cur < 1)
            page_cur = 1;//当前页小于1
        page_str = "<span>共" + total_num + "条</span><span>" + page_cur + "/" + page_total_num + "</span>";
        if (page_cur == 1) {//若是第一页
            page_str += "<span>首页</span><span>上一页</span>";
        } else {
            page_str += "<span><a href='javascript:void(1)' data-page='1'>首页</a></span><span><a href='javascript:void(" + (page_cur - 1) + ")' data-page='" + (page_cur - 1) + "'>上一页</a></span>";
        }

        if (page_total_num < 5){
            for (var i = 1; i <= page_total_num; i++) {
                if (i == page_str) {
                    page_str += "<span>" + i + "</span>";//当前页
                } else {
                    page_str += "<span><a href='javascript:void(" + i + ")' data-page='" + i + "'>" + i + "</a></span>";
                }
            }
        }else{
            if (page_cur < 3) {
                for (var i = 1; i <= 5; i++) {
                    if (i == page_cur) {
                        page_str += "<span>" + i + "</span>";//当前页
                    } else {
                        page_str += "<span><a href='javascript:void(" + i + ")' data-page='" + i + "'>" + i + "</a></span>";
                    }
                }
            } else {
                var cur = parseInt(page_cur) + 2;
                if (cur <= page_total_num) {
                    var pre = parseInt(page_cur) - 2;
                    var last = parseInt(page_cur) + 2;
                    for (i = pre; i <= last; i++) {
                        if (i == page_cur) {
                            page_str += "<span>" + i + "</span>";//当前页
                        } else {
                            page_str += "<span><a href='javascript:void(" + i + ")' data-page='" + i + "'>" + i + "</a></span>";
                        }
                    }
                } else {
                    var pre = parseInt(page_total_num) - 4;
                    for (i = pre; i <= parseInt(page_total_num); i++) {
                        if (i == page_cur) {
                            page_str += "<span>" + i + "</span>";//当前页
                        } else {
                            page_str += "<span><a href='javascript:void(" + i + ")' data-page='" + i + "'>" + i + "</a></span>";
                        }
                    }
                }
            }
        }
        if (page_cur >= page_total_num) {//若是最后页
            page_str += "<span>下一页</span><span>尾页</span>";
        } else {
            page_str += "<span><a href='javascript:void(" + (parseInt(page_cur) + 1) + ")' data-page='" + (parseInt(page_cur) + 1) + "'>下一页</a></span><span><a href='javascript:void(" + page_total_num + ")' data-page='" + page_total_num + "'>尾页</a></span>";
        }


        $("#page").html(page_str);
    }

    $(function() {
        getData(1);//默认第一页
        $(document).delegate('#page a','click', function() { //live 向未来的元素添加事件处理器,不可用bind
            var page = $(this).attr("data-page");//获取当前页
            getData(page);
        });
    });

    /**
     * 首页
     */
    function firstPage() {
        getData(1);
    }

    /**
     * 尾页
     */
    function lastPage() {
        var totalPages = $("#totalPages").val();
        getData(totalPages);
    }


    /**
     * 上一页
     */
    function prePage() {
        var currPageNum = parseInt($("#currPageNum").val());
        var tempPageNum = 1;

        if (currPageNum > 0) {
            tempPageNum = currPageNum - 1;
        }
        if (tempPageNum == 0) {
            tempPageNum = 1;
        }
        getData(tempPageNum);
    }

    /**
     * 跳转下一页
     */
    function nextPage() {
        var currPageNum = parseInt($("#currPageNum").val());
        var totalPages = parseInt($("#totalPages").val());
        var tempPageNum;

        if (currPageNum >= totalPages) {
            tempPageNum = totalPages;
        } else {
            tempPageNum = parseInt(currPageNum) + 1;
        }
        getData(tempPageNum);
    }
</script>
{/literal}

<div class="search_list">
    <div class="search_crumbs">
        <p class="fl">全部结果<i class="ffs">></i></p>
        <p class="fl crumbattr"><a href="#">品种：HDPE</a><i class="close">关闭</i></p>
        <p class="fl crumbattr"><a href="#">币种：人民币</a><i class="close">关闭</i></p>
        <p class="fl"><i class="ffs">></i></p>
        <p class="fl crumbattr_search"><input type="text" placeholder="在当前条件下搜索" class="crumbsearch-input"/><input class="crumbsearch-btn" value="" type="button"/></p>
        <p class="fr">共<span class="blue fwb fs16">1271</span>件相关商品</p>
    </div>


    <div class="nav_prop">
        <div class="nav_variety">
            <span class="fl">品　种</span>
            <div class="search_wrap_text">
                <a href="#">HDPE</a><a href="#">LDPE</a><a href="#">LLDPE</a><a href="#">PP</a><a href="#">MLLDPE</a>
            </div>
        </div>
        <div class="nav_rmb">
            <span class="fl">币　种</span>
            <div class="search_wrap_text">
                <a href="#">人民币</a><a href="#">美金</a>
            </div>
        </div>
        <div class="nav_area">
            <span class="fl">地　区</span>
            <div class="search_wrap_text">
                <div class="search_te">
                    <a href="#">上海</a><a href="#">广东</a><a href="#">北京</a><a href="#">深圳</a><a href="#">广州</a>
                    <a href="#">上海</a><a href="#">广东</a><a href="#">北京</a><a href="#">深圳</a><a href="#">广州</a>
                    <a href="#">上海</a><a href="#">广东</a><a href="#">北京</a><a href="#">深圳</a><a href="#">广州</a>
                    <a href="#">上海</a><a href="#">广东</a><a href="#">北京</a><a href="#">深圳</a><a href="#">广州</a>
                    <a href="#">上海</a><a href="#">广东</a><a href="#">北京</a><a href="#">深圳</a><a href="#">广州</a>
                    <a href="#">上海</a><a href="#">广东</a><a href="#">北京</a><a href="#">深圳</a><a href="#">广州</a>
                </div>
                <div class="swt_text stms1"><span>更多</span><i></i></div>
            </div>

        </div>
        <!--<div class="nav_grade">
        	<span class="fl">牌　号</span>
            <div class="search_wrap_text">

                <div class="search_te">
                <a href="#">F00952</a><a href="#">2426H</a><a href="#">7050h</a><a href="#">2426H</a><a href="#">2426H</a>
                <a href="#">LF2119</a><a href="#">P740J</a><a href="#">52518</a><a href="#">F800E</a><a href="#">Q281</a>
                <a href="#">F00952</a><a href="#">2426H</a><a href="#">7050h</a><a href="#">2426H</a><a href="#">2426H</a>
                <a href="#">LF2119</a><a href="#">P740J</a><a href="#">52518</a><a href="#">F800E</a><a href="#">Q281</a>
                <a href="#">F00952</a><a href="#">2426H</a><a href="#">7050h</a><a href="#">2426H</a><a href="#">2426H</a>
                <a href="#">LF2119</a><a href="#">P740J</a><a href="#">52518</a><a href="#">F800E</a><a href="#">Q281</a>
                </div>
                <div class="swt_text stms2"><span>更多</span><i></i></div>
            </div>

        </div>-->
        <!--<div class="nav_manufacturer">
        	<span class="fl">厂　商</span>
            <div class="search_wrap_text">
            	<div class="search_te">
                    <a href="#">扬子巴斯夫</a><a href="#">镇海石化</a><a href="#">扬子巴斯夫</a><a href="#">伊朗石化 </a><a href="#">上海石化 </a>
                    <a href="#">沙特sabic</a><a href="#">扬子巴斯夫</a><a href="#">镇海石化</a><a href="#">扬子巴斯夫</a><a href="#">伊朗石化 </a><a href="#">上海石化 </a>
                    <a href="#">沙特sabic</a><a href="#">扬子巴斯夫</a><a href="#">镇海石化</a><a href="#">扬子巴斯夫</a><a href="#">伊朗石化 </a><a href="#">上海石化 </a>
                    <a href="#">沙特sabic</a><a href="#">扬子巴斯夫</a><a href="#">镇海石化</a><a href="#">扬子巴斯夫</a><a href="#">伊朗石化 </a><a href="#">上海石化 </a>
                    <a href="#">沙特sabic</a>
                </div>
                <div class="swt_text stms3"><span>更多</span><i></i></div>
            </div>

        </div>-->


        <div class="search_prot">品种：<input type="text" class="orit"/>地区：<input type="text" class="orit"/>牌号：<input type="text" class="orit"/>厂商：<input type="text" class="orit"/><input class="orit_btn" type="button" value="搜 索"/></div>

    </div>


    <div class="search_text_wrap">

        <div class="search_menb">
            <div class="relsearch">
                <a href="#" class="fsort curr">综合<i></i></a>
                <a href="#" class="fsort">数量<i></i></a>
                <a href="#" class="pirce">价格<i></i></a>
                <div class="place_delivery">

                    <div class="place_dtt">交货地：<span class="pd_text">上海</span><i class="pd_b"></i></div>

                    <div class="place_de_popup">
                        <h3 class="place_de_h3">选择收货城市</h3>
                        <p class="place_de_p"><a href="#">北京</a><a href="#">天津</a><a href="#">上海</a><a href="#">重庆</a><a href="#">河北</a><a href="#">山西</a>
                            <a href="#">内蒙古</a><a href="#">辽宁</a><a href="#">吉林</a><a href="#">黑龙江</a><a href="#">江苏</a><a href="#">浙江</a>
                            <a href="#">安徽</a><a href="#">福建</a><a href="#">江西</a><a href="#">山东</a><a href="#">河南</a><a href="#">湖北</a>
                            <a href="#">湖南</a><a href="#">广东</a><a href="#">广西</a><a href="#">黑龙江</a><a href="#">江苏</a><a href="#">浙江</a>
                        </p>
                    </div>

                </div>

                <div class="ppld_input"><input type="text" placeholder="¥最低价"/>-<input type="text" placeholder="¥最高价"/></div>
                <input type="button" class="ppld_btn" value="确定"/>

                <div class="ppld_flip"><p class="fl"><span class="blue" id="currPage"></span>/<span id="totalPage"></span></p>

                    <a href="javascript:void(0)" onclick="prePage()" class="left_btn ffs lb_default"><</a>
                    <a href="javascript:void(0)" onclick="nextPage()" class="right_btn ffs lb_default">></a>

                </div>

            </div>
        </div>
    </div>



    <div class="product">

        <div class="product_title">
            <span class="items breed">品种</span>
            <span class="items grade">牌号</span>
            <span class="items firm">厂商</span>
            <span class="items price">价格(元/吨)</span>
            <span class="items number">数量（吨）</span>
            <span class="items supplier">供应商</span>
            <span class="items operate">操作</span>
        </div>
        <input type="hidden" value="" id="currPageNum">
        <input type="hidden" value="" id="totalPages">
        <ul class="product_iwrap">
            <!--{foreach from=$userlist key=key item=item}-->
            <!--<li class="product_item">-->
                <!--<div class="product_list_title">-->
                    <!--<span class="items icons">+</span>-->
                    <!--<span class="items breed">{$item.cate_name}</span>-->
                    <!--<span class="items grade">{$item.product_name}</span>-->
                    <!--<span class="items firm">{$item.brand_name}</span>-->
                    <!--<span class="items price orange fwb">{$item.price}</span>-->
                    <!--<span class="items number">{$item.num}</span>-->
                    <!--<span class="items supplier blue">4家报价</span>-->
                    <!--<span class="items operate"><a href="#">查看</a></span>-->
                <!--</div>-->

                <!--<ul class="product_list_content">-->
                    <!--{foreach from=$item.list key=keys item=items}-->
                    <!--<li>-->
                        <!--<div class="plc_items">-->
                            <!--<div class="items plc_items_text"><i class="plc_icon">自营现货</i>-->
                                <!--<p class="plc_text">{$items.cate_name}  {$items.product_name} {$items.brand_name}   <span class="green">现货</span></p>-->
                            <!--</div>-->
                            <!--<span class="items firm">交货地：上海宝山</span>-->
                            <!--<span class="items price blue fwb">{$items.price} </span>-->
                            <!--<span class="items number">{$items.num} </span>-->
                            <!--<span class="items time">4分钟前</span>-->
                            <!--<span class="items operate">-->
                                <!--<a href="#" class="buy">立即认购</a><a href="#" class="negotiate">委托洽谈</a>-->
                            <!--</span>-->
                        <!--</div>-->
                    <!--</li>-->
                    <!--{/foreach}-->
                <!--</ul>-->

            <!--</li>-->
            <!--{/foreach}-->
        </ul>
    </div>



    <!--<div class="page tar ptb10p" id="page"> {$links}</div>-->
    <div class="page tar ptb10p" id="page"></div>




</div>

{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/footer.html"}